home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / animSweep.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  3.8 KB  |  119 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  Oct. 31/97
  22. //  Author:         clm
  23. //
  24. //  Description:
  25. //      animSweep operates on NURBS curves, generally that are animated.
  26. //    It will take snapshots of the curve at each of the times between a
  27. //    min and max time with an increment, copy the curves
  28. //
  29. //  Input Arguments:
  30. //        float    minTime        - start time of sweep
  31. //        float    maxTime        - end time of sweep
  32. //        int        ts            - if true, use the time slider range for the
  33. //                              min/max times of the sweep; otherwise use
  34. //                              minTime and maxTime.
  35. //        float    by            - increment for snapshot of objects to sweep
  36. //        float    hist        - if true, keep history on after the sweep is
  37. //                              finished, so that changes to the original
  38. //                              animated object will affect the swept object
  39. //        int        deg            - degree of swept surface produced
  40. //        int        uniform        - if true, make the swept surface w. uniform knots
  41. //        int        close        - if true, make the swept surface closed
  42. //        int        poly        - if true, make the swept surface a polygonal object
  43. //
  44. //  Return Value:
  45. //      Returns the number of swept surfaces that were produced
  46. //    (one per selected animated curve)
  47. //
  48.  
  49.  
  50. proc int animSweepOne(string $curve, float $minTime, float $maxTime, int $ts,
  51.             float $by, int $hist, int $deg, int $uniform, int $close, int $poly)
  52. {
  53.     // Note that we want to query the time slider range at the time we
  54.     // execute the command, so that if the action was dragged to the
  55.     // shelf, it will re-query the time slider range each time it is executed.
  56.     //
  57.     if ($ts == 1)
  58.     {
  59.         $minTime = `playbackOptions -query -minTime`;
  60.         $maxTime = `playbackOptions -query -maxTime`;
  61.     }
  62.  
  63.     string $result[] = `snapshot -startTime $minTime -endTime $maxTime
  64.                         -increment $by -constructionHistory $hist $curve`;
  65.  
  66.     if (size($result) == 0)
  67.     {
  68.         error(("could not snapshot '"+$curve+"'"));
  69.         return 0;
  70.     }
  71.  
  72.     // Do the loft
  73.     //
  74.     if (catch (`loft
  75.                 -uniform $uniform -close $close
  76.                 -degree $deg -polygon $poly
  77.                 -ch $hist
  78.                 $result[0]`))
  79.     {
  80.         error(("could not loft result of snapshot '"+$curve+"'"));
  81.         return 0;
  82.     }
  83.  
  84.     // If construction history is off, delete the curves that snapshot
  85.     // generated (which will also delete the snapshot node)
  86.     //
  87.     if (!$hist)
  88.     {
  89.         delete $result[0];
  90.     }
  91.  
  92.     return 1;
  93. }
  94.  
  95. global proc int animSweep(float $minTime, float $maxTime, int $ts,
  96.                           float $by, int $hist,
  97.                           int $deg, int $uniform, int $close, int $poly)
  98. {
  99.     // Walk through all the shapes on the selection list, and
  100.     // anim sweep all the nurbsCurve shapes
  101.     //
  102.     int $processed = 0;
  103.     string $result[] = `ls -sl -dag -lf -showType`;
  104.     for ($i = 0; $i < size($result); $i+=2)
  105.     {
  106.         if ($result[$i+1] == "nurbsCurve")
  107.         {
  108.             animSweepOne($result[$i], $minTime, $maxTime, $ts, $by, $hist,
  109.                         $deg, $uniform, $close, $poly);
  110.             $processed = 1;
  111.         }
  112.     }
  113.  
  114.     if ($processed == 0)
  115.         warning("No curves to Animation Sweep");
  116.  
  117.     return 1;
  118. }
  119.